<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel app\models\search\AsrAudioClassifySerach */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '';
$this->params['breadcrumbs'][] = '语音流程种类';
?>
<div class="asr-audio-classify-index">

    <p>
        <?= Html::a('新增分类', ['create'], ['class' => 'btn  btn-default btn-lg fa fa-plus']) ?>
    </p>

    <div class="box">
        <div class="box-header">
            <h3 class="box-title">语音流程分类列表</h3>
        </div>
        <!-- /.box-header -->
        <div class="box-body">
        <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            ['attribute'=>'name',
                'footer' => '
                    <input id="num" class="btn btn-default btn-xs btn-delete" placeholder="每页显示的条数" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,\'\')}else{this.value=this.value.replace(/\D/g,\'\')}" onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,\'\')}else{this.value=this.value.replace(/\D/g,\'\')}">
                ',
            ],
            ['attribute' => 'create_at',
                'value'=>
                    function($model){
                        return  date('Y-m-d H:i:s',$model->create_at);
                    },
            ],

            ['class' => 'yii\grid\ActionColumn',//下面是新增加的按按钮
                'header'=>'操作',
                'template' => ' {update}&nbsp;&nbsp;&nbsp;{delete} ',
                'buttons' => [
                    'update' => function ( $url,$model) {
                        return  '<a href="'.$url.'" class="btn btn-info fa fa-edit">修改</a>';
                    },
                    'delete' => function ( $url,$model) {
                        return  '<a href="'.$url.'" title="删除" aria-label="删除" data-pjax="0" data-confirm="您确定要删除此项吗？" data-method="post"><span class="btn btn-danger fa fa-remove">删除</span></a>';
                    },
                ],
                'options'=>[
                    'width'=>'20%',
                ],
                'footerOptions' => ['colspan' => 1],  //设置删除按钮垮列显示；
            ]
        ],
        'filterModel' => $searchModel,
        'showFooter' => true,  //设置显示最下面的footer
        'pager'=>[
            'firstPageLabel'=>"第一页",
            'lastPageLabel'=>'最后一页',
            'options'=>[
                'class'=>'pagination pagination-sm no-margin pull-right'
            ],
        ],
        'tableOptions'=>[
            'class'=>'table table-hover'
        ]
    ]); ?>
        </div>
    </div>
</div>
<script type="text/javascript">
    $('#num').blur(function(){//当鼠标失去焦点是触发事件,实现用户自定义分页
        var url = "<?= 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] ?>";
        $.ajax({
            type:'post',
            async:true,
            url:url,
            data:{pageSize:$('#num').val()},
            success:function(data){
                window.location.reload();
            },
            error:function(error){

            }
        });
    });
    $('#asrRes').click(function(){
        $(this).attr('hidden','hidden');
    });
</script>
